#pragma once

#include "EXEditResSet.h"

#define WM_DEF_ENCHANGE (WM_USER+151)

// CEXEdit

class AFX_EXT_CLASS CEXEdit : public CEdit
{
	DECLARE_DYNAMIC(CEXEdit)

public:
  enum EDIT_STYLE
  {
    NOIMAGE,
    EDIT_CTRL = 14,
  };

	CEXEdit();
	virtual ~CEXEdit();

	void DrawBitmap( CDC * pDC );
	BOOL SetBgBitmaps(UINT nBkgndID, int nCount, COLORREF crBkgnd, 
                    int nTopHeight = 0, int nBottomHeight = 0, 
                    int nLeftWidth = 0, int nRightWidth = 0);

	BOOL InitBgBitmap(CBitmap & src, int index, int count, COLORREF & crBkgnd);
	BOOL EnableWindow(BOOL bEnable = TRUE);

	void ModifyRect();

  void SetResSet(CEXBaseResSet* pResSet);
  CEXEditResSet* m_pEditResSet;

	enum timer
	{
		IDT_LEAVE = 1,
		IDT_DISABLE,
	};

	enum STATUS
	{
		normal,
		focus,
		select,
		disable
	};

	BOOL m_bLoaded;
	UINT m_nBkgndID;
	int m_nNumofBgPics;
	int m_nStatus;

	CBitmap m_bmpBkgnd;

	int m_nTopHeight;
	int m_nBottomHeight;
	int m_nLeftWidth;
	int m_nRightWidth;

	COLORREF m_crTransparent;
	COLORREF m_crBkgnd;

	COLORREF m_crNormal;
	COLORREF m_crSelect;
	COLORREF m_crFocus;
	COLORREF m_crDisable;

	CBrush m_brBkgnd;
	CBrush m_brNormal;
	CBrush m_brSelect;
	CBrush m_brFocus;
	CBrush m_brDisable;

	UINT m_nTimer;

protected:
	DECLARE_MESSAGE_MAP()
	virtual void PreSubclassWindow();
public:
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnSetFocus(CWnd* pOldWnd);
	afx_msg void OnKillFocus(CWnd* pNewWnd);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnNcPaint();
	afx_msg void OnEnChange();
	afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
	afx_msg void OnDestroy();
	virtual BOOL PreTranslateMessage(MSG* pMsg);
};


